package com.qqt.csr.order.controller;

import com.qqt.csr.common.interceptor.auth.Authorize;
import com.qqt.csr.common.session.SessionContextHolder;
import com.qqt.csr.common.vo.resp.ObjectResponse;
import com.qqt.csr.common.vo.resp.PageResponse;
import com.qqt.csr.order.service.WorkOrderService;
import com.qqt.csr.order.vo.req.QueryPageWorkOrderReqVO;
import com.qqt.csr.order.vo.resp.CsWorkOrderCountRespVO;
import com.qqt.csr.order.vo.resp.WorkOrderDetailRespVO;
import com.qqt.csr.order.vo.resp.WorkOrderRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: yang hao
 * @Date: 2024/12/18 14:29
 * @Description: 工单管理
 **/
@Authorize
@RestController
@RequestMapping("order/work/manage")
@Tag(name = "工单管理", description = "工单管理")
public class WorkOrderController {

    @Autowired
    private WorkOrderService workOrderService;

    @PostMapping("/page")
    @Operation(summary = "分页查询工单")
    public PageResponse<WorkOrderRespVO> page(@RequestBody QueryPageWorkOrderReqVO reqVO) {
        return workOrderService.page(reqVO);
    }

    @GetMapping("/detail/{id}")
    @Operation(summary = "工单详情")
    public ObjectResponse<WorkOrderDetailRespVO> detail(@PathVariable("id") Long id) {
        return ObjectResponse.success(workOrderService.detail(id));
    }

    @GetMapping("/home/count")
    @Operation(summary = "首页工单数量统计")
    public ObjectResponse<CsWorkOrderCountRespVO> homeCount() {
        Long csId = SessionContextHolder.getHeaderInfo().getUserId();
        return ObjectResponse.success(workOrderService.getHomeCount(csId));
    }



}
